package com.wedu.modules.sys.redis;

import com.wedu.common.utils.RedisKeys;
import com.wedu.common.utils.RedisUtils;
import com.wedu.modules.sys.entity.GameEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GameRedis {
    @Autowired
    private RedisUtils redisUtils;

    public void saveOrUpdate(GameEntity game) {
        if(game == null){
            return ;
        }
        String key = RedisKeys.getGameKey(game.getGameName());
        redisUtils.set(key, game);
    }
    public void delete(String gameKey) {
        String key = RedisKeys.getGameKey(gameKey);
        redisUtils.delete(key);
    }
    public GameEntity get(String gameKey){
        String key = RedisKeys.getGameKey(gameKey);
        return redisUtils.get(key, GameEntity.class);
    }

}
